import {Module} from '@nestjs/common';
import {JwtModule} from '@nestjs/jwt';
import {PassportModule} from '@nestjs/passport';
import {JwtStrategy} from './jwt.strategy';
import {AuthController} from './auth.controller';
import {AuthService} from './auth.service';
import {ConfigService} from "@nestjs/config";
import {UserService} from "../user/user.service";
import {UserModule} from "../user/user.module";


@Module({
    imports: [
        UserModule,
        PassportModule.register({defaultStrategy: 'jwt'}),
        JwtModule.registerAsync({
            useFactory: (configService: ConfigService) => ({
                secret: configService.get('JWT_SECRET'),
                signOptions: {expiresIn: configService.get('JWT_EXPIRES_IN')},
            }),
            inject: [ConfigService],
        })
    ],
    controllers: [AuthController],
    providers: [AuthService, JwtStrategy, UserService],
    exports: [AuthService, PassportModule],
})
export class AuthModule {
}
